<?php

class DefaultController extends MyUserController
{
	public function actions() {
		return array(
			'captcha' => array(
//				'class' => 'ext.kcaptcha.KCaptchaAction',
				'class' => 'CCaptchaAction',
				'backColor' => 0xFFFFFF,
			),
		);
	}

	public function actionIndex()
	{
		$model=new ContactForm;
		if(isset($_POST['ContactForm']))
		{
			$model->attributes=$_POST['ContactForm'];
			if($model->validate())
			{
				$userModel = new User();
				$userModel = $userModel->findByPk(User::ADMIN_ID);
				Yii::app()->mailer->AddAddress($userModel->getAttribute('email'));
				Yii::app()->mailer->Subject = $model->subject;
				Yii::app()->mailer->From = $model->email;
				Yii::app()->mailer->MsgHTML($model->body);
				Yii::app()->mailer->Send();

				Yii::app()->user->setFlash('contact',tt('Thank you for contacting us. We will respond to you as soon as possible.'));
				$this->refresh();
			}
		}
		$this->render('contact',array('model'=>$model));
	}
}